package com.xinchuang.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.ArrayList;

import java.util.*;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xinchuang.role.config.RoleConfig;
import com.xinchuang.role.entity.SystemHeader;
import com.xinchuang.service.actual.CloseQuestionService;
import com.xinchuang.utils.MyUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import com.xinchuang.utils.CheckUtil;
import com.xinchuang.comment.R;

import com.xinchuang.utils.DateUtils;
import org.apache.commons.lang3.StringUtils;
import com.xinchuang.service.RecordAndStatisticModService;
import org.springframework.web.multipart.MultipartFile;

/**
 * RecordAndStatisticModController
 *
 * @date 2023-07-05
 */
@RestController
@RequestMapping("/recordAndStatisticMod")
@Api(value = "记录评审与统计模块", tags = "记录评审与统计模块")
public class RecordAndStatisticModController {
    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    @Resource
    private RecordAndStatisticModService recordAndStatisticModService;

    @Resource
    private CloseQuestionService closeQuestionService;

    @Resource
    private RoleConfig roleConfig;

    /**
     * 上传图片接口接口接口  函数名称imageUpload  功能描述:统一的上传图片接口
     *
     * @param file 中文名:图片文件
     * @return 返回参数{}
     */
    @PostMapping("/imageUpload")
    @ApiOperation("上传图片接口接口")
    public R imageUpload(
            @RequestParam(value = "file", required = false) MultipartFile file
    ) {
        // 调用业务层代码
        String r = closeQuestionService.imageUpload(file);
        return JSON.parseObject(r, R.class);
    }

    /**
     * 试模记录列表接口接口  函数名称tryOutRecordList  功能描述:
     *
     * @param jsonObject 中文名:通用实体类
     * @return 返回参数{}
     */
    @PostMapping("/tryOutRecordList")
    @ApiOperation("试模记录列表接口")
    public R tryOutRecordList(@RequestBody JSONObject jsonObject) {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        Set<String> sSet = new HashSet<>();
        String result = jsonLoop(jsonObject, "", methodName + "SC", sSet);
        result = result + tryOutRecordListACS(sSet);
        if (result.length() > 0) {
            return R.fail("入参：" + result);
        } else {
            // 调用业务层代码
            R r = recordAndStatisticModService.tryOutRecordList(jsonObject);
            return r;
        }
    }

    /**
     * 试模问题关闭统计表查询接口  函数名称tryOutColsedQuestion  功能描述:
     *
     * @param jsonObject 中文名:通用实体类
     * @return 返回参数{}
     */
    @PostMapping("/tryOutColsedQuestion")
    @ApiOperation("试模问题关闭统计表查询")
    public R tryOutColsedQuestion(@RequestBody JSONObject jsonObject) {
        // 调用业务层代码
        String r = closeQuestionService.tryOutColsedQuestion(jsonObject);
        return JSON.parseObject(r, R.class);
    }

    /**
     * 保存试模记录评审表接口接口  函数名称addTryOutRecord  功能描述:
     *
     * @param jsonObject 中文名:通用实体类
     * @return 返回参数{}
     */
    @PostMapping("/addTryOutRecord")
    @ApiOperation("保存试模记录评审表接口")
    public R addTryOutRecord(@RequestBody JSONObject jsonObject, HttpServletRequest request) {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        Set<String> sSet = new HashSet<>();
        String result = jsonLoop(jsonObject, "", methodName + "SC", sSet);
        result = result + addTryOutRecordACS(sSet);
        if (false) {
            return R.fail("入参：" + result);
        } else {
            // 调用业务层代码
            String r = recordAndStatisticModService.addTryOutRecord(jsonObject, request);
            Set<String> aSet = new HashSet<>();
            JSONObject o = JSON.parseObject(r);
            if (o == null) {
                o = new JSONObject();
            }
            result = jsonLoop(o.get("data"), "", methodName + "AC", aSet);
            result = result + addTryOutRecordACB(aSet);
            if (result.length() > 0) {
                return R.fail("出参：" + result);
            }
            return JSON.parseObject(r, R.class);
        }
    }

    /**
     * 提交评审记录接口接口  函数名称postTryOutToCheck  功能描述:
     *
     * @param jsonObject 中文名:通用实体类
     * @return 返回参数{}
     */
    @PostMapping("/postTryOutToCheck")
    @ApiOperation("提交评审记录接口")
    public R postTryOutToCheck(@RequestBody JSONObject jsonObject, HttpServletRequest request) {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        Set<String> sSet = new HashSet<>();
        String result = jsonLoop(jsonObject, "", methodName + "SC", sSet);
        result = result + postTryOutToCheckACS(sSet);
        if (result.length() > 0) {
            return R.fail("入参：" + result);
        } else {
            // 调用业务层代码
            String r = recordAndStatisticModService.postTryOutToCheck(jsonObject, request);
            Set<String> aSet = new HashSet<>();
            JSONObject o = JSON.parseObject(r);
            if (o == null) {
                o = new JSONObject();
            }
            result = jsonLoop(o.get("data"), "", methodName + "AC", aSet);
            result = result + postTryOutToCheckACB(aSet);
            if (result.length() > 0) {
                return R.fail("出参：" + result);
            }
            return JSON.parseObject(r, R.class);
        }
    }

    /**
     * 导出评审记录表格接口接口  函数名称exportTryOutRecord  功能描述:
     *
     * @param jsonObject 中文名:通用实体类
     * @return 返回参数{}
     */
    @PostMapping("/exportTryOutRecord")
    @ApiOperation("导出评审记录表格接口")
    public R exportTryOutRecord(@RequestBody JSONObject jsonObject, HttpServletResponse response) throws IOException {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        Set<String> sSet = new HashSet<>();
        String result = jsonLoop(jsonObject, "", methodName + "SC", sSet);
        result = result + exportTryOutRecordACS(sSet);
        if (result.length() > 0) {
            return R.fail("入参：" + result);
        } else {
            // 调用业务层代码
            String r = recordAndStatisticModService.exportTryOutRecord(jsonObject, response);
            Set<String> aSet = new HashSet<>();
            JSONObject o = JSON.parseObject(r);
            if (o == null) {
                o = new JSONObject();
            }
            result = jsonLoop(o.get("data"), "", methodName + "AC", aSet);
            result = result + exportTryOutRecordACB(aSet);
            if (result.length() > 0) {
                return R.fail("出参：" + result);
            }
            return JSON.parseObject(r, R.class);
        }
    }

    /**
     * 试模问题关闭统计表保存接口接口  函数名称addTryOutColsedQuestion  功能描述:
     *
     * @param jsonObject 中文名:通用实体类
     * @return 返回参数{}
     */
    @PostMapping("/addTryOutColsedQuestion")
    @ApiOperation("试模问题关闭统计表保存接口")
    public R addTryOutColsedQuestion(@RequestBody JSONObject jsonObject, HttpServletRequest request) {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        Set<String> sSet = new HashSet<>();
        String result = jsonLoop(jsonObject, "", methodName + "SC", sSet);
        result = result + addTryOutColsedQuestionACS(sSet);
        if (result.length() > 0) {
            return R.fail("入参：" + result);
        } else {
            // 调用业务层代码
            String r = closeQuestionService.addTryOutColsedQuestion(jsonObject);
            Set<String> aSet = new HashSet<>();
            JSONObject o = JSON.parseObject(r);
            if (o == null) {
                o = new JSONObject();
            }
            result = jsonLoop(o.get("data"), "", methodName + "AC", aSet);
            result = result + addTryOutColsedQuestionACB(aSet);
            if (result.length() > 0) {
                return R.fail("出参：" + result);
            }
            return JSON.parseObject(r, R.class);
        }
    }


    public static String jsonLoop(Object object, String result, String methodName, Set<String> set) {
        Object v = null;
        if (object instanceof JSONArray || object instanceof ArrayList) {
            JSONArray jsonArray = new JSONArray();
            if (object instanceof ArrayList) {
                jsonArray = JSONArray.parseArray(JSON.toJSONString(object));
            } else {
                jsonArray = (JSONArray) object;
            }
            for (int i = 0; i < jsonArray.size(); i++) {
                result = jsonLoop(jsonArray.get(i), result, methodName, set);
                if (StringUtils.isNotEmpty(result)) {
                    return result;
                }
            }
        }
        if (object instanceof JSONObject) {
            JSONObject jsonObject = (JSONObject) object;
            for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
                Object o = entry.getValue();
                if (o instanceof JSONArray || o instanceof ArrayList) {
                    result += selectCheckMathod(entry.getKey(), entry.getValue(), methodName, set);
                    result = jsonLoop(o, result, methodName, set);
                    if (StringUtils.isNotEmpty(result)) {
                        return result;
                    }
                } else if (o instanceof JSONObject) {
                    result = jsonLoop(o, result, methodName, set);
                    if (StringUtils.isNotEmpty(result)) {
                        return result;
                    }
                } else {
//                   FIXME: 未知类型
                }
                v = entry.getValue();
                result += selectCheckMathod(entry.getKey(), v, methodName, set);
            }
        }
        return result;
    }

    private static String selectCheckMathod(String key, Object value, String methodName, Set<String> set) {
        String result = "";
        if ("tryOutRecordListSC".equals(methodName)) {
            result = tryOutRecordListSC(key, value, set);
        }
        if ("tryOutRecordListAC".equals(methodName)) {
            result = tryOutRecordListAC(key, value, set);
        }
        if ("tryOutColsedQuestionSC".equals(methodName)) {
            result = tryOutColsedQuestionSC(key, value, set);
        }
        if ("tryOutColsedQuestionAC".equals(methodName)) {
            result = tryOutColsedQuestionAC(key, value, set);
        }
        if ("addTryOutRecordSC".equals(methodName)) {
            result = addTryOutRecordSC(key, value, set);
        }
        if ("addTryOutRecordAC".equals(methodName)) {
            result = addTryOutRecordAC(key, value, set);
        }
        if ("postTryOutToCheckSC".equals(methodName)) {
            result = postTryOutToCheckSC(key, value, set);
        }
        if ("postTryOutToCheckAC".equals(methodName)) {
            result = postTryOutToCheckAC(key, value, set);
        }
        if ("exportTryOutRecordSC".equals(methodName)) {
            result = exportTryOutRecordSC(key, value, set);
        }
        if ("exportTryOutRecordAC".equals(methodName)) {
            result = exportTryOutRecordAC(key, value, set);
        }
        if ("addTryOutColsedQuestionSC".equals(methodName)) {
            result = addTryOutColsedQuestionSC(key, value, set);
        }
        if ("addTryOutColsedQuestionAC".equals(methodName)) {
            result = addTryOutColsedQuestionAC(key, value, set);
        }
        return result;
    }


    private static String tryOutRecordListSC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("moldId".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "模具编号", isNull, 0, 255);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String tryOutRecordListAC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("status".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "审核状态", isNull, "0", "255");
        }
        if ("code".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "状态码", isNull, "0", "100000");
        }
        if ("msg".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "返回消息", isNull, 0, 255);
        }
        if ("success".equals(key)) {
            // 判断参数类型: String  num boolean datetime
        }
        if ("projectName".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "项目名称", isNull, 0, 255);
        }
        if ("moldName".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "模具名称", isNull, 0, 255);
        }
        if ("moldId".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "模具工号", isNull, 0, 255);
        }
        if ("moldMaterial".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "产品材质", isNull, 0, 255);
        }
        if ("moldWeight".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "产品重量", isNull, 0, 255);
        }
        if ("mainEnginePlantId".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "主机厂Id", isNull, 0, 255);
        }
        if ("projectManager".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "项目责任人", isNull, 0, 255);
        }
        if ("moldDesigner".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "设计责任人", isNull, 0, 255);
        }
        if ("tongmanName".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "钳工责任人", isNull, 0, 255);
        }
        if ("surfaceRequire".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "产品表面要求", isNull, 0, 255);
        }
        if ("partsStorageBinId".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "零件厂Id", isNull, 0, 255);
        }
        if ("tryOutTimeOfT0".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "T0试模时间", isNull, 0, 255);
        }
        if ("stageData".equals(key)) {
            result += CheckUtil.checkJSONArray(JSONArray.parseArray(JSON.toJSONString(value)), "阶段数据", isNull);
        }
        if ("stageNo".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "问题提出阶段", isNull, 0, 255);
        }
        if ("image".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "略图", isNull, 0, 255);
        }
        if ("questionPoint".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "问题点", isNull, 0, 255);
        }
        if ("questionTypeName".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "问题归类", isNull, 0, 255);
        }
        if ("totalQuestionCount".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "问题总数", isNull, 0, 255);
        }
        if ("needToChangeCount".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "待整改问题数", isNull, 0, 255);
        }
        if ("reason".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "原因", isNull, 0, 255);
        }
        if ("reasonTypeName".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "原因归类", isNull, 0, 255);
        }
        if ("reasonSourceId".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "问题来源Id", isNull, 0, 255);
        }
        if ("expertGroup".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "专家组", isNull, 0, 255);
        }
        if ("departMentName".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "责任部门名称", isNull, 0, 255);
        }
        if ("responsiblePerson".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "责任人名称", isNull, 0, 255);
        }
        if ("plannedCompletionTime".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "计划完成时间", isNull, 0, 255);
        }
        if ("selfCheck".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "责任人自检", isNull, 0, 255);
        }
        if ("remediationAction".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "整改方案", isNull, 0, 255);
        }
        if ("tryOutResultData".equals(key)) {
            result += CheckUtil.checkJSONArray(JSONArray.parseArray(JSON.toJSONString(value)), "试验结果", isNull);
        }
        if ("stageName".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "阶段名称", isNull, 0, 255);
        }
        if ("stateValue".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "状态值", isNull, 0, 255);
        }
        if ("planValue".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "计划值", isNull, 0, 255);
        }
        if ("realValue".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "实际值", isNull, 0, 255);
        }
        if ("projectManager".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "拟定人", isNull, 0, 255);
        }
        if ("checkoutName".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "审核", isNull, 0, 255);
        }
        if ("countersign".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "会签", isNull, 0, 255);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String tryOutColsedQuestionSC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("moldId".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "模具工号", isNull, 0, 255);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String tryOutColsedQuestionAC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("code".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "状态码", isNull, "0", "100000");
        }
        if ("msg".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "返回消息", isNull, 0, 255);
        }
        if ("success".equals(key)) {
            // 判断参数类型: String  num boolean datetime
        }
        if ("projectName".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "项目名称", isNull, 0, 255);
        }
        if ("moldName".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "产品名称", isNull, 0, 255);
        }
        if ("moldId".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "模具工号", isNull, 0, 255);
        }
        if ("moldMaterial".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "产品材质", isNull, 0, 255);
        }
        if ("moldWeight".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "产品重量", isNull, 0, 255);
        }
        if ("mainEnginePlantId".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "主机厂Id", isNull, 0, 255);
        }
        if ("projectManager".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "项目责任人", isNull, 0, 255);
        }
        if ("moldDesigner".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "设计责任人", isNull, 0, 255);
        }
        if ("tongmanName".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "钳工责任人", isNull, 0, 255);
        }
        if ("surfaceRequire".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "产品表面要求", isNull, 0, 255);
        }
        if ("partsStorageBin".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "零件厂", isNull, 0, 255);
        }
        if ("tryOutTime".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "T0试模时间", isNull, 0, 255);
        }
        if ("stageData".equals(key)) {
            result += CheckUtil.checkJSONArray(JSONArray.parseArray(JSON.toJSONString(value)), "试模阶段数据", isNull);
        }
        if ("stageName".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "阶段名称", isNull, 0, 255);
        }
        if ("reason".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "试模原因", isNull, 0, 255);
        }
        if ("plannedTime".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            Date date = DateUtils.parseStringTimeToDate(value == null ? "" : value.toString());
            if (date == null) {
                result += "时间格式错误:null";
            } else {
                result += CheckUtil.checkDate(date, "计划试模时间", isNull);
            }
        }
        if ("realTime".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "实际试模时间", isNull, 0, 255);
        }
        if ("raisedCount".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "新增问题数", isNull, 0, 255);
        }
        if ("totalCount".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "问题总数", isNull, 0, 255);
        }
        if ("plannedDoneCount".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "计划本次解决数", isNull, 0, 255);
        }
        if ("closedCount".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "本次已关闭问题数", isNull, 0, 255);
        }
        if ("needToChangeCount".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "待整改问题数", isNull, 0, 255);
        }
        if ("stageCloseRate".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "阶段问题关闭率", isNull, 0, 255);
        }
        if ("totalCloseRate".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "总问题关闭率", isNull, 0, 255);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String addTryOutRecordSC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("stageNo".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "问题提出阶段 	stageNo", isNull, 0, 255);
        }
        if ("moldId".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "模具工号", isNull, 0, 255);
        }
        if ("stageData".equals(key)) {
            result += CheckUtil.checkJSONArray(JSONArray.parseArray(JSON.toJSONString(value)), "阶段数据", isNull);
        }
        if ("image".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "略图", isNull, 0, 255);
        }
        if ("questionPoint".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "问题点", isNull, 0, 255);
        }
        if ("questionTypeName".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "问题归类", isNull, 0, 255);
        }
        if ("totalQuestionCount".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "问题总数", isNull, "0", "255");
        }
        if ("needToChangeCount".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "待整改问题数", isNull, "0", "255");
        }
        if ("reason".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "原因", isNull, 0, 255);
        }
        if ("reasonTypeName".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "原因归类", isNull, 0, 255);
        }
        if ("reasonSourceId".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "问题来源", isNull, 0, 255);
        }
        if ("responsiblePersonData".equals(key)) {
            result += CheckUtil.checkJSONArray(JSONArray.parseArray(JSON.toJSONString(value)), "责任人", isNull);
        }
        if ("departMentName".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "责任部门名称", isNull, 0, 255);
        }
        if ("responsiblePerson".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "责任人名称", isNull, 0, 255);
        }
        if ("plannedCompletionTime".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "计划完成时间", isNull, 0, 255);
        }
        if ("selfCheck".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "责任人自检", isNull, 0, 255);
        }
        if ("remediationAction".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "整改方案", isNull, 0, 255);
        }
        if ("expertGroup".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "专家组", isNull, 0, 255);
        }
        if ("tryOutResultData".equals(key)) {
            result += CheckUtil.checkJSONArray(JSONArray.parseArray(JSON.toJSONString(value)), "试验结果", isNull);
        }
        if ("stageName".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "阶段名称", isNull, 0, 255);
        }
        if ("stateValue".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "状态值", isNull, 0, 255);
        }
        if ("planValue".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "计划值", isNull, 0, 255);
        }
        if ("realValue".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "实际值", isNull, 0, 255);
        }
        if ("projectManager".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "拟定人", isNull, 0, 255);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String addTryOutRecordAC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("code".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "状态码", isNull, "0", "100000");
        }
        if ("msg".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "返回消息", isNull, 0, 255);
        }
        if ("success".equals(key)) {
            // 判断参数类型: String  num boolean datetime
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String postTryOutToCheckSC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("moldId".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "模具工号", isNull, 0, 255);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String postTryOutToCheckAC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("code".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "状态码", isNull, "0", "100000");
        }
        if ("msg".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "返回消息", isNull, 0, 255);
        }
        if ("success".equals(key)) {
            // 判断参数类型: String  num boolean datetime
        }
        if ("审核状态".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "审核状态", isNull, "0", "3");
        }
        if ("moldId".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "模具工号", isNull, 0, 255);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String exportTryOutRecordSC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("moldId".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "模具Id", isNull, 0, 255);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String exportTryOutRecordAC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("success".equals(key)) {
            // 判断参数类型: String  num boolean datetime
        }
        if ("msg".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "返回消息", isNull, 0, 255);
        }
        if ("code".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "状态码", isNull, "0", "100000");
        }
        if ("filePath".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "excel表格路径", isNull, 0, 255);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String addTryOutColsedQuestionSC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("moldId".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "模具工号", isNull, 0, 255);
        }
        if ("stageData".equals(key)) {
            result += CheckUtil.checkJSONArray(JSONArray.parseArray(JSON.toJSONString(value)), "试模阶段数据", isNull);
        }
        if ("stageName".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "阶段名称", isNull, 0, 255);
        }
        if ("reason".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "试模原因", isNull, 0, 255);
        }
        if ("plannedTime".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "计划试模时间", isNull, 0, 255);
        }
        if ("realTime".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "实际试模时间", isNull, 0, 255);
        }
        if ("raisedCount".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "新增问题数", isNull, 0, 255);
        }
        if ("totalCount".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "问题总数", isNull, 0, 255);
        }
        if ("plannedDoneCount".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "计划本次解决数", isNull, 0, 255);
        }
        if ("closedCount".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "本次已关闭问题数", isNull, 0, 255);
        }
        if ("needToChangeCount".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "待整改问题数", isNull, 0, 255);
        }
        if ("stageCloseRate".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "阶段问题关闭率", isNull, 0, 255);
        }
        if ("totalCloseRate".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "总问题关闭率", isNull, 0, 255);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String addTryOutColsedQuestionAC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("code".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "状态码", isNull, "0", "100000");
        }
        if ("msg".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "返回消息", isNull, 0, 255);
        }
        if ("success".equals(key)) {
            // 判断参数类型: String  num boolean datetime
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String tryOutRecordListACS(Set<String> set) {
        List<String> list = new ArrayList<>();
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "入参");
    }

    private static String tryOutRecordListACB(Set<String> set) {
        List<String> list = new ArrayList<>();
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "出参");
    }

    private static String tryOutColsedQuestionACS(Set<String> set) {
        List<String> list = new ArrayList<>();
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "入参");
    }

    private static String tryOutColsedQuestionACB(Set<String> set) {
        List<String> list = new ArrayList<>();
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "出参");
    }

    private static String addTryOutRecordACS(Set<String> set) {
        List<String> list = new ArrayList<>();
        list.add("projectManager");
        list.add("reason");
        list.add("reasonTypeName");
        list.add("planValue");
        list.add("plannedCompletionTime");
        list.add("reasonSourceId");
        list.add("stateValue");
        list.add("needToChangeCount");
        list.add("expertGroup");
        list.add("questionTypeName");
        list.add("totalQuestionCount");
        list.add("realValue");
        list.add("remediationAction");
        list.add("selfCheck");
        list.add("stageNo");
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "入参");
    }

    private static String addTryOutRecordACB(Set<String> set) {
        List<String> list = new ArrayList<>();
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "出参");
    }

    private static String postTryOutToCheckACS(Set<String> set) {
        List<String> list = new ArrayList<>();
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "入参");
    }

    private static String postTryOutToCheckACB(Set<String> set) {
        List<String> list = new ArrayList<>();
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "出参");
    }

    private static String exportTryOutRecordACS(Set<String> set) {
        List<String> list = new ArrayList<>();
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "入参");
    }

    private static String exportTryOutRecordACB(Set<String> set) {
        List<String> list = new ArrayList<>();
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "出参");
    }

    private static String addTryOutColsedQuestionACS(Set<String> set) {
        List<String> list = new ArrayList<>();
        list.add("realTime");
        list.add("reason");
        list.add("totalCloseRate");
        list.add("raisedCount");
        list.add("stageCloseRate");
        list.add("plannedTime");
        list.add("plannedDoneCount");
        list.add("totalCount");
        list.add("needToChangeCount");
        list.add("closedCount");
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "入参");
    }

    private static String addTryOutColsedQuestionACB(Set<String> set) {
        List<String> list = new ArrayList<>();
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "出参");
    }

    /**
     * 获取集合中的不同值
     *
     * @param list
     * @param set
     * @return
     */
    private static String getCollectionDifferentValue(List<String> list, Set<String> set, String flag) {
        String result = "";
        for (String str : list) {
            if (!set.contains(str)) {
                result += str + ",";
            }
        }
        if (StringUtils.isNotEmpty(result)) {
            result = StringUtils.strip(result, ",");
            result = "---" + flag + ":" + result + "为必填参数";
        }
        return result;
    }
}
